package com.sishu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sishu.pojo.Locationrecord;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface LocationrecordMapper extends BaseMapper<Locationrecord> {

    @Select("select * from locationrecord where location_id = #{locationId}")
    List<Locationrecord> selectbylocationid(int locationId);

    //根据siteid和userid,组id查询购买记录
    @Select("select * from locationrecord where location_id = #{locationId} and s_id = #{sId} and group_id =#{groupId}")
    Locationrecord selectbylocationIdandsid(String sId, int locationId, String groupId);


    @Select("delete from locationrecord where s_id = #{sId} and location_id = #{locationId} and group_id = #{groupId}")
    void deleteground(String sId, int locationId, String groupId);

    @Select("delete from locationrecord where s_id = #{sId}  and group_id = #{groupId}")
    void deleteallground(String sId, String groupId);

    @Select("select * from locationrecord where s_id = #{sId} and group_id = #{groupId}")
    List<Locationrecord> selectbysidandgroupid(String sId, String groupId);

    @Update("update locationrecord set upgrade_times = #{upgradeTimes},upgrade_price = #{upgradePrice} where s_id = #{sId} and location_id = #{locationId} and group_id = #{groupId}")
    void updateupgradetimesandprice(String sId, int locationId, String groupId, int upgradeTimes, int upgradePrice);

    @Select("select * from locationrecord where group_id = #{groupId} and location_type = #{locationType}")
    List<Locationrecord> selectbylocationidandgroupid(String groupId, String locationType);
}
